home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-21 | 2.6 KB | 92 lines | [TEXT/ttxt] |
- --<<<
- -- Filename:
- -- grphclab.sx
-
- -- Other Files Required:
- -- None
-
- -- Purpose:
- -- Class definitions for text labels and buttons with graphic backgrounds
-
- -- Specialized Classes:
- -- graphicLabel, graphicLabelButton
-
- -- Instructions to User:
- -- The graphicLabel specializes the built-in TwoDMultiPresenter class
- -- to create a class that combines a textbox with a twoDShape to create a
- -- settable (but not editable) text field over a graphic background.
- -- Instance variables:
- -- name: a string, the object's name
- -- textField: a TextPresenter, containing the text displayed over the background.
-
- -- Authors:
- -- Steve Gano, Dionn M. Stewart
-
- in module Autofinder
-
- class GraphicLabel (TwoDMultiPresenter)
- instance variables
- textField -- a text presenter
- instance methods
- method targetSetter self value -> (
- if (isAKindOf value String) then
- (
- self.textField.target := value
- return value
- )
- else
- nextMethod self value
- )
- end
-
- -- Create a new graphicLabel with:
- -- bkgnd: twoDshape for the background
- -- vmarg, hmarg: integers, the vertical and horizontal margins
- -- fontChanges: keyed linked list of text attributes to change
- method init self {class GraphicLabel} #rest args #key \
- background:(new TwoDshape boundary:(new Rect x2:100 y2:100) fill:undefined) \
- hmarg:(0) \
- vmarg:(0) \
- fontChanges:(new KeyedLinkedList) \
- label:("") ->
- (
- -- Derive the boundary of the presenter from the background.
- local bnds := new Rect x2:background.width y2:background.height
- apply nextMethod self target:undefined boundary:bnds args
-
- -- Make the textPresenter
- -- Inset the background bounds by given margins to make text box boundary
- bnds := new Rect x2:(background.width - (2 * hmarg)) \
- y2:(background.height - vmarg)
- self.textField := new TextPresenter boundary:bnds target:(label as Text)
-
- -- Set the text box attributes.
- forEachBinding fontChanges (key val arg ->
- setDefaultAttr self.textField key val
- ) undefined
- self.textField.x := hmarg
- self.textField.y := vmarg
- append self background
- prepend self self.textField
- self
- )
-
- -- The graphicLabelButton class specializes graphicLabel by mixing in
- -- the built-in Actuator class, which lets it act like a button.
- -- Instance variables:
- -- authorData: optional data to be passed to the depressAction
- class GraphicLabelButton (GraphicLabel, Actuator)
- instance variables
- authorData -- any user defined object
- end
-
- method init self {class GraphicLabelButton} #rest args \
- #key authorData:(undefined) ->
- (
- apply nextMethod self args
- self.authorData := authorData
- )
-
- "Compiled grphclab.sx"
- -->>>
-